<?php

// +----------------------------------------------------------------------
// | MyCentOS
// +----------------------------------------------------------------------
// | Copyright (c) 2014 http://www.mycentos.com, All rights reserved.
// +----------------------------------------------------------------------
// | Author: 琥珀 <317559272@qqq.com><http://www.mycentos.com>
// +----------------------------------------------------------------------
// | @date  : 2015-04-09 10:44:22
// +----------------------------------------------------------------------
// | @Last Modified by:  琥珀
// +----------------------------------------------------------------------
// | @Last Modified time: 2015-04-27 17:08:39
// +-----------------------------------------------------------------------


/**
 * 首页
 */
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller
{

    /**
     * [index 首页默认]
     * @return [array] [返回首页资料]
     */
    public function index($category = null) {
        $category = I('category');
        if ($category) {
            $map['category_id'] = intval($category);
        } else {
            $map = array();
        }
        $article =M('Article');
        $count      = $article->where('status=1')->count();
        $Page       = new \Think\Page($count,10);
        $show       = $Page->show();
        $list = $article->where('status=1')->order('addtime')->where($map)->limit($Page->firstRow.','.$Page->listRows)->select();
        $this->assign('article',$list);
        $this->assign('page',$show);
        $this->assign('active',$category);
        $this->display();
    }
}
